package com.fingard.dsp.bank.directbank.citic01;


import com.fingard.constant.Format;
import com.fingard.dsp.bank.directbank.PaymentState;
import com.fingard.dsp.bank.directbank.bankInterface.ISinglePay;
import com.fingard.dsp.bank.reqrespobj.batpayrec.ReqBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.ReqQryBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.RetAtsBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.RetAtsQryBatPayRec;
import com.fingard.dsp.bank.reqrespobj.single.*;
import com.fingard.dsp.bank.reqrespobj.single.detail.RetAtsSglDetail;
import com.fingard.net.ConnState;
import com.fingard.text.StringHelper;
import com.fingard.util.DateHelper;
import com.fingard.xml.XElement;
import com.fingard.xml.XmlTextReader;
import com.fingard.xml.XmlTextWriter;

import java.util.Date;
import java.util.concurrent.TimeUnit;

public class CITIC01SinglePay extends CITIC01Base implements ISinglePay {

    //单笔支付，不需采用流处理方式
    public RetAtsSingle d_1908_SglPay(ReqSingle p_req1908) throws Exception {
        //返回ATS的对象
        RetAtsSingle retAts = new RetAtsSingle(p_req1908.reqHeader);
        RetAtsSglDetail tmpRetDetail = null;
        if (("1".equals(p_req1908.singleDetail.sameBnk) && "1".equals(p_req1908.singleDetail.isPrivate)) && "190804".equals(p_req1908.reqHeader.commandCode)) {
            tmpRetDetail = d_190801DLEXPENS(p_req1908);
        } else if ("6908".equals(p_req1908.reqHeader.transType) && "690803".equals(p_req1908.reqHeader.commandCode)) {
            //银联跨行代付（单笔），转批量
            this.WriteBankLogLn("转银联跨行代付（2018）");
            ReqBatPayRec p_req1988 = new ReqBatPayRec(p_req1908);//单笔转批量
            CITIC01BatPayRec tmpBatPay = new CITIC01BatPayRec();
            tmpBatPay.setSbLog(this.sbLog);
            tmpBatPay.setLogFlushTime(this.logFlushTime);
            //tmpBatPay.isFromSinglePay = true;
            tmpBatPay.reqHeader = p_req1908.reqHeader.clone();
            tmpBatPay.reqHeader.transType = "1988";
            tmpBatPay.reqHeader.commandCode = "198808";
            tmpBatPay.bankFront = this.bankFront;
            p_req1988.reqHeader = tmpBatPay.reqHeader;
            RetAtsBatPayRec retAts1988 = tmpBatPay.d_1988_BatPay(p_req1988);
            tmpRetDetail = retAts1988.convertToSingle();
        } else if ("190801".equals(p_req1908.reqHeader.commandCode)) {//内部转账
            if (getBankConfig().getValueAsBool("useNewVerSglPay")) {
                tmpRetDetail = d_SglPayNew(p_req1908);
            } else {
                if (p_req1908.singleDetail.recHigherLevelAct.equals(p_req1908.singleDetail.payHigherLevelAct) && "6".equals(p_req1908.reqHeader.actBankType)) {
                    tmpRetDetail = virtual_7528(p_req1908);
                } else {
                    tmpRetDetail = d_190801(p_req1908);
                }
            }
        } else if ("190801A".equals(p_req1908.reqHeader.commandCode)) {//上划下拨
            if (p_req1908.singleDetail.primaryAct != null && !"".equals(p_req1908.singleDetail.primaryAct)) {
                if ("0".equals(p_req1908.singleDetail.primaryAct) || "1".equals(p_req1908.singleDetail.primaryAct)) {
                    tmpRetDetail = d_190801A(p_req1908);
                } else {
                    tmpRetDetail = new RetAtsSglDetail();
                    tmpRetDetail.respCode = "0";
                    tmpRetDetail.respInfo = "交易类型类别不是归集下拨";
                    tmpRetDetail.transState = PaymentState.FAIL_Payment;
                    tmpRetDetail.payInfoCode = "E1301";
                }
            }
        } else if ("7527".equals(p_req1908.reqHeader.commandCode) && "6".equals(p_req1908.reqHeader.actBankType)) {//虚拟附属账户调账
            tmpRetDetail = virtual_7527(p_req1908);
        } else if (("7528".equals(p_req1908.reqHeader.commandCode) && "6".equals(p_req1908.reqHeader.actBankType))
                || ("190802F".equals(p_req1908.reqHeader.commandCode))) {//虚拟附属账户强制转账
            tmpRetDetail = virtual_7528(p_req1908);
        } else if (!p_req1908.singleDetail.payAct.equals(p_req1908.singleDetail.payHigherLevelAct) && "190802".equals(p_req1908.reqHeader.commandCode) && "6".equals(p_req1908.reqHeader.actBankType)) {//虚拟附属账户对外付款
            if (getBankConfig().getValueAsBool("forcePayForSubAct")) {
                tmpRetDetail = virtual_7528(p_req1908);
            } else {
                tmpRetDetail = virtual_190802(p_req1908);
            }
        } else if (!StringHelper.isNullOrEmpty(p_req1908.singleDetail.payHigherLevelAct) && "190802".equals(p_req1908.reqHeader.commandCode) && "2".equals(p_req1908.reqHeader.actBankType)
                && !p_req1908.singleDetail.payAct.equals(p_req1908.singleDetail.payHigherLevelAct)) {//3.5.1 附属账户支付转账
            tmpRetDetail = sub_190802(p_req1908);
        } else {
            if (getBankConfig().getValueAsBool("useNewVerSglPay") || "190803".equals(p_req1908.reqHeader.commandCode)) {
                tmpRetDetail = d_SglPayNew(p_req1908);
            } else {
                tmpRetDetail = d_190802(p_req1908);
            }
        }
        if (tmpRetDetail.respCode.equals("-1") && StringHelper.isNullOrEmpty(tmpRetDetail.reqSeqID)) {
            tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;
        }
        retAts.writeRetDetail(tmpRetDetail);
        return retAts;
    }

    //使用财务报销接口DLEXPENS,做同行对私转账
    private RetAtsSglDetail d_190801DLEXPENS(ReqSingle p_req1908) throws Exception {
        RetAtsSglDetail retDetail = new RetAtsSglDetail();
        CITIC01Header bankHeader = new CITIC01Header();
        bankHeader.action = "DLEXPENS";
        XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
        xmlWriter.writeStartDocByDeclaration("<?xml version=\"1.0\" encoding=\"GBK\"?>");
        //需要进行对账码拼接以及节点解析，采用XElement进行处理
        //单笔、批量共用节点赋值方法
        XElement tmpXElement = new XElement("stream", "");
        tmpXElement.addChild(new XElement("action", bankHeader.action));
        tmpXElement.addChild(new XElement("userName", bankFront.loginName));
        tmpXElement.addChild(new XElement("clientID", p_req1908.singleDetail.askNumber));
        if (StringHelper.isNullOrEmpty(p_req1908.singleDetail.bookDate) || DateHelper.compareDay(new Date(), Format.Date10Format.parse(p_req1908.singleDetail.bookDate)) >= 0 || "true".equals(getBankConfig().getValueAsString("disablePrePay").toLowerCase())) {
            tmpXElement.addChild(new XElement("preFlg", "0"));
            tmpXElement.addChild(new XElement("preDate", ""));
            tmpXElement.addChild(new XElement("preTime", ""));
        } else {
            tmpXElement.addChild(new XElement("preFlg", "1"));
            tmpXElement.addChild(new XElement("preDate", p_req1908.singleDetail.bookDate.replace("-", "")));
            tmpXElement.addChild(new XElement("preTime", "100000"));
        }
        tmpXElement.addChild(new XElement("payAccountNo", p_req1908.singleDetail.payAct));
        tmpXElement.addChild(new XElement("recAccountNo", p_req1908.singleDetail.recAct));
        tmpXElement.addChild(new XElement("recAccountName", p_req1908.singleDetail.recName));
        tmpXElement.addChild(new XElement("tranAmount", p_req1908.singleDetail.payAmount));
        tmpXElement.addChild(new XElement("abstract", p_req1908.singleDetail.abstractATS));

        nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());

        xmlWriter.writeXElement(tmpXElement);
        xmlWriter.writeEndDocument();//写入报文完成

        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送银行
        if (tmpStrRet[0].length() == 0) {
            StringBuilder tmpSbMsg = new StringBuilder();
            //解析银行返回
            XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
            if (tmpBkReader != null) {
                retDetail.respCode = "0";
                retDetail.respInfo = tmpBkReader.getFirstText("/stream/statusText");
                retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                retDetail.transState = tmpBkReader.getFirstText("/stream/status");
                retDetail.payInfoCode = retDetail.transState;
                retDetail.transAmt = tmpBkReader.getFirstText("/stream/tranAmount");
                deal_ED11308(retDetail);
            } else {
                retDetail.respCode = "-1";
                retDetail.respInfo = tmpSbMsg.toString();
            }
        } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
            retDetail.respCode = "0";
            retDetail.respInfo = tmpStrRet[1];
            retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
            retDetail.transState = PaymentState.FAIL_Payment;
            retDetail.payInfoCode = tmpStrRet[0];
        } else {
            retDetail.respCode = "-1";
            retDetail.respInfo = tmpStrRet[1];
        }
        return retDetail;
    }

    //3.5.1 附属账户支付转账，银行接口已更新，V6.0.0.0，3.5.1 资金分簿支付转账
    private RetAtsSglDetail sub_190802(ReqSingle p_req1908) throws Exception {
        //返回ATS的对象
        RetAtsSglDetail retDetail = new RetAtsSglDetail();
        CITIC01Header bankHeader = new CITIC01Header();
        bankHeader.action = "DLINTSUB";
        XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
        writeCommonHeader(xmlWriter, bankHeader);
        xmlWriter.writeStartElementByAttr("list", "<list name=\"userDataList\">");
        XElement tmpXElement = new XElement("row", "");
        tmpXElement.addChild(new XElement("clientID", p_req1908.singleDetail.askNumber));
        if (StringHelper.isNullOrEmpty(p_req1908.singleDetail.bookDate) || DateHelper.compareDay(new Date(), Format.Date10Format.parse(p_req1908.singleDetail.bookDate)) >= 0 || "true".equals(getBankConfig().getValueAsString("disablePrePay").toLowerCase())) {
            tmpXElement.addChild(new XElement("preFlg", "0"));
            tmpXElement.addChild(new XElement("preDate", ""));
            tmpXElement.addChild(new XElement("preTime", ""));
        } else {
            tmpXElement.addChild(new XElement("preFlg", "1"));
            tmpXElement.addChild(new XElement("preDate", p_req1908.singleDetail.bookDate.replace("-", "")));
            tmpXElement.addChild(new XElement("preTime", "100000"));
        }
        /*<payType></payType>
         * <!--支付方式 1：跨行转账；2：行内；3：企业内部转账 char(1)-->*/
        String payType = "";
        if (p_req1908.reqHeader.commandCode.equals("190801")) {
            payType = "3";
        } else {
            if (p_req1908.singleDetail.sameBnk.equals("1")) {
                payType = "2";
            } else {
                payType = "1";
            }
        }
        tmpXElement.addChild(new XElement("payType", payType));
        tmpXElement.addChild(new XElement("payFlg", p_req1908.singleDetail.paySpd.equals("0") ? "1" : "0"));//支付时效 0：加急；1普通 char(1)
        tmpXElement.addChild(new XElement("mainAccNo", p_req1908.singleDetail.payHigherLevelAct));
        tmpXElement.addChild(new XElement("payAccountNo", p_req1908.singleDetail.payAct));
        tmpXElement.addChild(new XElement("recAccountNo", p_req1908.singleDetail.recAct));
        tmpXElement.addChild(new XElement("recAccountName", p_req1908.singleDetail.recName));
        tmpXElement.addChild(new XElement("recOpenBankName", p_req1908.singleDetail.cnapsName));
        tmpXElement.addChild(new XElement("recOpenBankCode", p_req1908.singleDetail.cnapsCode));
        tmpXElement.addChild(new XElement("tranAmount", p_req1908.singleDetail.payAmount));
        tmpXElement.addChild(new XElement("abstract", p_req1908.singleDetail.purpose));
        nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());
        xmlWriter.writeXElement(tmpXElement);
        xmlWriter.writeEndDocument();
        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送银行
        if (tmpStrRet[0].length() == 0) {
            StringBuilder tmpSbMsg = new StringBuilder();
            //解析银行返回
            XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
            if (tmpBkReader != null) {
                String tmpStatus = tmpBkReader.getFirstText("/stream/status");
                String tmpStatusText = tmpBkReader.getFirstText("/stream/statusText");
                if (isActiveRetCode(tmpStatus)) {
                    while (tmpBkReader.read("/stream/list/row")) {
                        if (!p_req1908.singleDetail.askNumber.equals(tmpBkReader.readedXElement.getSingleTextNotNull("clientID"))) {
                            continue;
                        }
                        retDetail.respCode = "0";
                        retDetail.respInfo = tmpBkReader.readedXElement.getSingleTextNotNull("statusText");
                        retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                        retDetail.transState = tmpBkReader.readedXElement.getSingleTextNotNull("status");
                        retDetail.payInfoCode = retDetail.transState;
                    }
                } else {
                    retDetail.respCode = "-1";
                    retDetail.respInfo = tmpStatusText;
                }
            } else {
                retDetail.respCode = "-1";
                retDetail.respInfo = tmpSbMsg.toString();
            }
        } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
            retDetail.respCode = "0";
            retDetail.respInfo = tmpStrRet[1];
            retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
            retDetail.transState = PaymentState.FAIL_Payment;
            retDetail.payInfoCode = tmpStrRet[0];
        } else {
            retDetail.respCode = "-1";
            retDetail.respInfo = tmpStrRet[1];
        }
        return retDetail;
    }

    @Override
    public RetAtsSingleBat d_1908BAT_SglBatPay(ReqSingleBat p_req1908BAT) throws Exception {
        return null;
    }

    //190802对外支付
    private RetAtsSglDetail d_190802(ReqSingle p_req1908) throws Exception {
        RetAtsSglDetail retDetail = new RetAtsSglDetail();
        CITIC01Header bankHeader = new CITIC01Header();
        bankHeader.action = "DLOUTTRN";
        XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
        xmlWriter.writeStartDocByDeclaration("<?xml version=\"1.0\" encoding=\"GBK\"?>");
        //需要进行对账码拼接以及节点解析，采用XElement进行处理
        //单笔、批量共用节点赋值方法
        XElement tmpXElement = new XElement("stream", "");
        tmpXElement.addChild(new XElement("action", bankHeader.action));
        tmpXElement.addChild(new XElement("userName", bankFront.loginName));
        tmpXElement.addChild(new XElement("clientID", p_req1908.singleDetail.askNumber));
        if (StringHelper.isNullOrEmpty(p_req1908.singleDetail.bookDate) || DateHelper.compareDay(new Date(), Format.Date10Format.parse(p_req1908.singleDetail.bookDate)) >= 0 || "true".equals(getBankConfig().getValueAsString("disablePrePay").toLowerCase())) {
            tmpXElement.addChild(new XElement("preFlg", "0"));
            tmpXElement.addChild(new XElement("preDate", ""));
            tmpXElement.addChild(new XElement("preTime", ""));
        } else {
            tmpXElement.addChild(new XElement("preFlg", "1"));
            tmpXElement.addChild(new XElement("preDate", p_req1908.singleDetail.bookDate.replace("-", "")));
            tmpXElement.addChild(new XElement("preTime", "100000"));
        }
        /*<payType></payType>
         * <!--支付方式 00：汇票； 01：中信内部转账；02：大额支付；03：小额支付；04：同城票交char(2) ；05：网银跨行支付-->*/
        String payType = "";
        if (p_req1908.singleDetail.sameBnk.equals("1")) {
            payType = "01";
        } else {//跨行
            if (p_req1908.singleDetail.isLargeAmt()) {
                payType = "02";
            } else if (p_req1908.singleDetail.paySpd.equals("1")) {//加急走大额
                payType = "02";
            } else if ("190805".equals(p_req1908.reqHeader.commandCode)) {
                payType = "05";
            } else if ("1".equals(p_req1908.singleDetail.sameCity) && true == getBankConfig().getValueAsBool("isPiaoJiao")) {
                payType = "04";
            } else {
                payType = "03";
            }
        }
        tmpXElement.addChild(new XElement("payType", payType));
        if (p_req1908.singleDetail.sameBnk.equals("1")) {
            tmpXElement.addChild(new XElement("recBankNo", ""));
        } else {
            tmpXElement.addChild(new XElement("recBankNo", p_req1908.singleDetail.cnapsCode));
        }
        tmpXElement.addChild(new XElement("payAccountNo", p_req1908.singleDetail.payAct));
        tmpXElement.addChild(new XElement("recAccountNo", p_req1908.singleDetail.recAct));
        tmpXElement.addChild(new XElement("recAccountName", p_req1908.singleDetail.recName));
        tmpXElement.addChild(new XElement("recOpenBankName", p_req1908.singleDetail.cnapsName));
        tmpXElement.addChild(new XElement("recOpenBankCode", p_req1908.singleDetail.cnapsCode));
        if (p_req1908.singleDetail.sameBnk.equals("1")) {
            tmpXElement.addChild(new XElement("citicbankFlag", "0"));//<!--中信标志 0：中信；1：他行 char(1)-->
            //<cityFlag></cityFlag><!--同城标志 0：同城；1：异地 char(1) 中信内转账可空-->
            tmpXElement.addChild(new XElement("cityFlag", ""));
        } else {
            tmpXElement.addChild(new XElement("citicbankFlag", "1"));
            if (p_req1908.singleDetail.sameCity.equals("1")) {
                tmpXElement.addChild(new XElement("cityFlag", "0"));
            } else {
                tmpXElement.addChild(new XElement("cityFlag", "1"));
            }
        }
        tmpXElement.addChild(new XElement("tranAmount", p_req1908.singleDetail.payAmount));
        tmpXElement.addChild(new XElement("abstract", p_req1908.singleDetail.abstractATS));
        tmpXElement.addChild(new XElement("memo", p_req1908.singleDetail.purpose));
        tmpXElement.addChild(new XElement("takerName", ""));
        tmpXElement.addChild(new XElement("takerID", ""));
        tmpXElement.addChild(new XElement("takerIDType", ""));

        nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());

        xmlWriter.writeXElement(tmpXElement);
        xmlWriter.writeEndDocument();//写入报文完成
        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送银行
        if (tmpStrRet[0].length() == 0) {
            StringBuilder tmpSbMsg = new StringBuilder();
            //解析银行返回
            XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
            if (tmpBkReader != null) {
                retDetail.respCode = "0";
                retDetail.respInfo = tmpBkReader.getFirstText("/stream/statusText");
                retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                retDetail.transState = tmpBkReader.getFirstText("/stream/status");
                retDetail.payInfoCode = retDetail.transState;
                retDetail.transAmt = tmpBkReader.getFirstText("/stream/tranAmount");
                deal_ED11308(retDetail);
            } else {
                retDetail.respCode = "-1";
                retDetail.respInfo = tmpSbMsg.toString();
            }
        } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
            retDetail.respCode = "0";
            retDetail.respInfo = tmpStrRet[1];
            retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
            retDetail.transState = PaymentState.FAIL_Payment;
            retDetail.payInfoCode = tmpStrRet[0];
        } else {
            retDetail.respCode = "-1";
            retDetail.respInfo = tmpStrRet[1];
        }
        return retDetail;
    }

    private void deal_ED11308(RetAtsSglDetail pDetail) {
        if ("ED11308".equals(pDetail.transState)) {
            pDetail.transState = pDetail.transState + "+" + pDetail.respInfo;
            pDetail.payInfoCode = pDetail.respInfo;
        }
    }

    private RetAtsSglDetail d_SglPayNew(ReqSingle p_req1908) throws Exception {
        RetAtsSglDetail retDetail = new RetAtsSglDetail();
        CITIC01Header bankHeader = new CITIC01Header();
        bankHeader.action = "DLINTTRN";
        XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
        xmlWriter.writeStartDocByDeclaration("<?xml version=\"1.0\" encoding=\"GBK\"?>");
        //需要进行对账码拼接以及节点解析，采用XElement进行处理
        //单笔、批量共用节点赋值方法
        xmlWriter.writeStartElement("stream");
        xmlWriter.writeElementString("action", bankHeader.action);
        xmlWriter.writeElementString("userName", bankFront.loginName);
        xmlWriter.writeStartElementByAttr("list", "<list name=\"userDataList\">");
        XElement tmpXElement = new XElement("row", "");

        tmpXElement.addChild(new XElement("clientID", p_req1908.singleDetail.askNumber));
        if (StringHelper.isNullOrEmpty(p_req1908.singleDetail.bookDate) || DateHelper.compareDay(new Date(), Format.Date10Format.parse(p_req1908.singleDetail.bookDate)) >= 0) {
            tmpXElement.addChild(new XElement("preFlg", "0"));
            tmpXElement.addChild(new XElement("preDate", ""));
            tmpXElement.addChild(new XElement("preTime", ""));
        } else {
            tmpXElement.addChild(new XElement("preFlg", "1"));
            tmpXElement.addChild(new XElement("preDate", p_req1908.singleDetail.bookDate.replace("-", "")));
            tmpXElement.addChild(new XElement("preTime", "100000"));
        }
        /*<payType></payType>
         * <!--支付方式 1：跨行转账；2：行内；3：企业内部转账 char(1)-->*/
        String payType = "";
        if (p_req1908.reqHeader.commandCode.equals("190801")) {
            payType = "3";
        } else {
            if (p_req1908.singleDetail.sameBnk.equals("1")) {
                payType = "2";
            } else {
                payType = "1";
            }
        }
        tmpXElement.addChild(new XElement("payType", payType));//支付方式 1：跨行转账；2：行内；3：企业内部转账 char(1)
        tmpXElement.addChild(new XElement("payFlg", p_req1908.singleDetail.paySpd.equals("0") ? "1" : "0"));//支付时效 0：加急；1普通 char(1)
        tmpXElement.addChild(new XElement("payAccountNo", p_req1908.singleDetail.payAct));
        tmpXElement.addChild(new XElement("recAccountNo", p_req1908.singleDetail.recAct));
        tmpXElement.addChild(new XElement("recAccountName", p_req1908.singleDetail.recName));
        tmpXElement.addChild(new XElement("recOpenBankName", p_req1908.singleDetail.cnapsName));
        tmpXElement.addChild(new XElement("recOpenBankCode", p_req1908.singleDetail.cnapsCode));
        tmpXElement.addChild(new XElement("tranAmount", p_req1908.singleDetail.payAmount));
        tmpXElement.addChild(new XElement("abstract", p_req1908.singleDetail.purpose));
        tmpXElement.addChild(new XElement("memo", p_req1908.singleDetail.memo));//备注 varchar(60) ，可空
        tmpXElement.addChild(new XElement("chkNum", p_req1908.singleDetail.abstractATS));//chkNum
        nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());

        xmlWriter.writeXElement(tmpXElement);
        xmlWriter.writeEndDocument();//写入报文完成
        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送银行
        if (tmpStrRet[0].length() == 0) {
            StringBuilder tmpSbMsg = new StringBuilder();
            //解析银行返回
            XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
            if (tmpBkReader != null) {
                String tmpStatus = tmpBkReader.getFirstText("/stream/status");
                String tmpStatusText = tmpBkReader.getFirstText("/stream/statusText");
                if (isActiveRetCode(tmpStatus)) {
                    while (tmpBkReader.read("/stream/list/row")) {
                        if (!p_req1908.singleDetail.askNumber.equals(tmpBkReader.readedXElement.getSingleTextNotNull("clientID"))) {
                            continue;
                        }
                        retDetail.respCode = "0";
                        retDetail.respInfo = tmpBkReader.readedXElement.getSingleTextNotNull("statusText");
                        retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                        retDetail.transState = tmpBkReader.readedXElement.getSingleTextNotNull("status");
                        retDetail.payInfoCode = retDetail.transState;
                        //retDetail.transAmt = tmpBkReader.getFirstText("/stream/tranAmount");
                        deal_ED11308(retDetail);
                    }
                } else {
                    retDetail.respCode = "-1";
                    retDetail.respInfo = tmpStatusText;
                    retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                }
            } else {
                retDetail.respCode = "-1";
                retDetail.respInfo = tmpSbMsg.toString();
            }
        } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
            retDetail.respCode = "0";
            retDetail.respInfo = tmpStrRet[1];
            retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
            retDetail.transState = PaymentState.FAIL_Payment;
            retDetail.payInfoCode = tmpStrRet[0];
        } else {
            retDetail.respCode = "-1";
            retDetail.respInfo = tmpStrRet[1];
        }
        return retDetail;
    }

    //190802 虚拟附属账户对外支付
    private RetAtsSglDetail virtual_190802(ReqSingle p_req1908) throws Exception {
        RetAtsSglDetail retDetail = new RetAtsSglDetail();
        CITIC01Header bankHeader = new CITIC01Header();
        bankHeader.action = "DLFCSOUT";
        XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
        xmlWriter.writeStartDocByDeclaration("<?xml version=\"1.0\" encoding=\"GBK\"?>");
        //需要进行对账码拼接以及节点解析，采用XElement进行处理
        //单笔、批量共用节点赋值方法
        XElement tmpXElement = new XElement("stream", "");
        tmpXElement.addChild(new XElement("action", bankHeader.action));
        tmpXElement.addChild(new XElement("userName", bankFront.loginName));
        tmpXElement.addChild(new XElement("clientID", p_req1908.singleDetail.askNumber));
        tmpXElement.addChild(new XElement("accountNo", p_req1908.singleDetail.payAct));
        tmpXElement.addChild(new XElement("recvAccNo", p_req1908.singleDetail.recAct));
        tmpXElement.addChild(new XElement("recvAccNm", p_req1908.singleDetail.recName));
        tmpXElement.addChild(new XElement("tranAmt", p_req1908.singleDetail.payAmount));
        tmpXElement.addChild(new XElement("sameBank", p_req1908.singleDetail.sameBnk.equals("1") ? "0" : "1"));//<!--中信标志 0：中信；1：他行 char(1)-->
        /*<payType></payType>
         * <!--支付方式 2H：大额支付；2B：小额支付；2E：网银跨行支付-->*/
        String payType = "";
        if (p_req1908.singleDetail.sameBnk.equals("1")) {
            payType = "";
        } else {//跨行
            if (p_req1908.singleDetail.isLargeAmt()) {
                payType = "2H";
            } else if (p_req1908.singleDetail.paySpd.equals("1")) {//加急走大额
                payType = getPayType();
            } else {
                Boolean needAppointPayType = getBankConfig().getValueAsBool("needAppointPayType");
                if (needAppointPayType == true) {
                    payType = getPayType();
                } else {
                    payType = "2B";
                }
            }
        }
        tmpXElement.addChild(new XElement("payType", payType));
        tmpXElement.addChild(new XElement("recvTgfi", p_req1908.singleDetail.cnapsCode));
        tmpXElement.addChild(new XElement("recvBankNm", p_req1908.singleDetail.cnapsName));
        tmpXElement.addChild(new XElement("memo", p_req1908.singleDetail.abstractATS + "-|-" + p_req1908.singleDetail.purpose));
        tmpXElement.addChild(new XElement("preFlg", "0"));
        tmpXElement.addChild(new XElement("preDate", ""));
        tmpXElement.addChild(new XElement("preTime", ""));
        tmpXElement.addChild(new XElement("tranFlag", "1"));

        nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());

        xmlWriter.writeXElement(tmpXElement);
        xmlWriter.writeEndDocument();//写入报文完成
        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送银行
        int payDelay = 0;
        try {
            payDelay = Integer.parseInt(getBankConfig().getValueAsString("payDelay"));
        } catch (Exception e) {
            payDelay = 0;
        }
        if (payDelay > 0) {
            //延时返回结果给mbs
            TimeUnit.SECONDS.sleep(payDelay);
        }
        if (tmpStrRet[0].length() == 0) {
            StringBuilder tmpSbMsg = new StringBuilder();
            //解析银行返回
            XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
            if (tmpBkReader != null) {
                retDetail.respCode = "0";
                retDetail.respInfo = tmpBkReader.getFirstText("/stream/statusText");
                retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                retDetail.transState = tmpBkReader.getFirstText("/stream/status");
                retDetail.payInfoCode = retDetail.transState;
                retDetail.transAmt = tmpBkReader.getFirstText("/stream/tranAmount");
                deal_ED11308(retDetail);
            } else {
                retDetail.respCode = "-1";
                retDetail.respInfo = tmpSbMsg.toString();
            }
        } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
            retDetail.respCode = "0";
            retDetail.respInfo = tmpStrRet[1];
            retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
            retDetail.transState = PaymentState.FAIL_Payment;
            retDetail.payInfoCode = tmpStrRet[0];
        } else {
            retDetail.respCode = "-1";
            retDetail.respInfo = tmpStrRet[1];
        }
        return retDetail;
    }

    //7527 虚拟附属账户调账
    private RetAtsSglDetail virtual_7527(ReqSingle p_req1908) throws Exception {
        RetAtsSglDetail retDetail = new RetAtsSglDetail();
        CITIC01Header bankHeader = new CITIC01Header();
        bankHeader.action = "DLTRSFIN";
        XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
        xmlWriter.writeStartDocByDeclaration("<?xml version=\"1.0\" encoding=\"GBK\"?>");
        //需要进行对账码拼接以及节点解析，采用XElement进行处理
        //单笔、批量共用节点赋值方法
        XElement tmpXElement = new XElement("stream", "");
        tmpXElement.addChild(new XElement("action", bankHeader.action));
        tmpXElement.addChild(new XElement("userName", bankFront.loginName));
        tmpXElement.addChild(new XElement("clientID", p_req1908.singleDetail.askNumber));
        tmpXElement.addChild(new XElement("accountNo", p_req1908.singleDetail.payAct));
        tmpXElement.addChild(new XElement("recvAccNo", p_req1908.singleDetail.recAct));
        tmpXElement.addChild(new XElement("recvAccNm", p_req1908.singleDetail.recName));
        tmpXElement.addChild(new XElement("tranAmt", p_req1908.singleDetail.payAmount));
        String[] tmpPurpose = p_req1908.singleDetail.purpose.split("-");
        if (tmpPurpose.length >= 3) {
            tmpXElement.addChild(new XElement("hostDate", tmpPurpose[0]));
            tmpXElement.addChild(new XElement("hostFlw", tmpPurpose[1]));
            tmpXElement.addChild(new XElement("hostSeq", tmpPurpose[2]));
            tmpXElement.addChild(new XElement("memo", p_req1908.singleDetail.abstractATS + "-|-调账入款"));

            nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());

            xmlWriter.writeXElement(tmpXElement);
            xmlWriter.writeEndDocument();//写入报文完成
            String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送银行
            if (tmpStrRet[0].length() == 0) {
                StringBuilder tmpSbMsg = new StringBuilder();
                //解析银行返回
                XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
                if (tmpBkReader != null) {
                    retDetail.respCode = "0";
                    retDetail.respInfo = tmpBkReader.getFirstText("/stream/statusText");
                    retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                    retDetail.transState = tmpBkReader.getFirstText("/stream/status");
                    retDetail.payInfoCode = retDetail.transState;
                    retDetail.transAmt = tmpBkReader.getFirstText("/stream/tranAmount");
                    deal_ED11308(retDetail);
                } else {
                    retDetail.respCode = "-1";
                    retDetail.respInfo = tmpSbMsg.toString();
                }
            } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
                retDetail.respCode = "0";
                retDetail.respInfo = tmpStrRet[1];
                retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                retDetail.transState = PaymentState.FAIL_Payment;
                retDetail.payInfoCode = tmpStrRet[0];
            } else {
                retDetail.respCode = "-1";
                retDetail.respInfo = tmpStrRet[1];
            }
        } else {
            retDetail.respCode = "-1";
            retDetail.respInfo = "调账数据不完整";
        }
        return retDetail;
    }

    //7528 虚拟附属强制转账
    private RetAtsSglDetail virtual_7528(ReqSingle p_req1908) throws Exception {
        RetAtsSglDetail retDetail = new RetAtsSglDetail();
        CITIC01Header bankHeader = new CITIC01Header();
        bankHeader.action = "DLMDETRN";
        XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
        xmlWriter.writeStartDocByDeclaration("<?xml version=\"1.0\" encoding=\"GBK\"?>");
        //需要进行对账码拼接以及节点解析，采用XElement进行处理
        //单笔、批量共用节点赋值方法
        XElement tmpXElement = new XElement("stream", "");
        tmpXElement.addChild(new XElement("action", bankHeader.action));
        tmpXElement.addChild(new XElement("userName", bankFront.loginName));
        tmpXElement.addChild(new XElement("clientID", p_req1908.singleDetail.askNumber));
        tmpXElement.addChild(new XElement("accountNo", p_req1908.singleDetail.payHigherLevelAct));
        tmpXElement.addChild(new XElement("payAccNo", p_req1908.singleDetail.payAct));
        tmpXElement.addChild(new XElement("tranType", "BF"));
        tmpXElement.addChild(new XElement("recvAccNo", p_req1908.singleDetail.recAct));
        tmpXElement.addChild(new XElement("recvAccNm", p_req1908.singleDetail.recName));
        tmpXElement.addChild(new XElement("tranAmt", p_req1908.singleDetail.payAmount));
        tmpXElement.addChild(new XElement("freezeNo", ""));
        tmpXElement.addChild(new XElement("ofreezeamt", ""));
        tmpXElement.addChild(new XElement("memo", p_req1908.singleDetail.abstractATS + "-|-" + p_req1908.singleDetail.purpose));
        tmpXElement.addChild(new XElement("tranFlag", "1"));

        nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());

        xmlWriter.writeXElement(tmpXElement);
        xmlWriter.writeEndDocument();//写入报文完成
        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送银行
        if (tmpStrRet[0].length() == 0) {
            StringBuilder tmpSbMsg = new StringBuilder();
            //解析银行返回
            XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
            if (tmpBkReader != null) {
                retDetail.respCode = "0";
                retDetail.respInfo = tmpBkReader.getFirstText("/stream/statusText");
                retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                retDetail.transState = tmpBkReader.getFirstText("/stream/status");
                retDetail.payInfoCode = retDetail.transState;
                retDetail.transAmt = tmpBkReader.getFirstText("/stream/tranAmount");
                deal_ED11308(retDetail);
            } else {
                retDetail.respCode = "-1";
                retDetail.respInfo = tmpSbMsg.toString();
            }
        } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
            retDetail.respCode = "0";
            retDetail.respInfo = tmpStrRet[1];
            retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
            retDetail.transState = PaymentState.FAIL_Payment;
            retDetail.payInfoCode = tmpStrRet[0];
        } else {
            retDetail.respCode = "-1";
            retDetail.respInfo = tmpStrRet[1];
        }

        return retDetail;
    }


    //190801内部转账
    private RetAtsSglDetail d_190801(ReqSingle p_req1908) throws Exception {
        RetAtsSglDetail retDetail = new RetAtsSglDetail();
        CITIC01Header bankHeader = new CITIC01Header();
        bankHeader.action = "DLINETRN";
        XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
        xmlWriter.writeStartDocByDeclaration("<?xml version=\"1.0\" encoding=\"GBK\"?>");
        //需要进行对账码拼接以及节点解析，采用XElement进行处理
        //单笔、批量共用节点赋值方法
        XElement tmpXElement = new XElement("stream", "");
        tmpXElement.addChild(new XElement("action", bankHeader.action));
        tmpXElement.addChild(new XElement("userName", bankFront.loginName));
        tmpXElement.addChild(new XElement("clientID", p_req1908.singleDetail.askNumber));
        tmpXElement.addChild(new XElement("preFlg", "0"));
        tmpXElement.addChild(new XElement("preDate", ""));
        tmpXElement.addChild(new XElement("preTime", ""));
        tmpXElement.addChild(new XElement("payAccountNo", p_req1908.singleDetail.payAct));
        tmpXElement.addChild(new XElement("recAccountNo", p_req1908.singleDetail.recAct));
        tmpXElement.addChild(new XElement("tranAmount", p_req1908.singleDetail.payAmount));
        tmpXElement.addChild(new XElement("abstract", p_req1908.singleDetail.abstractATS));
        tmpXElement.addChild(new XElement("memo", p_req1908.singleDetail.purpose));
        tmpXElement.addChild(new XElement("cryType", convertCurToBank(p_req1908.singleDetail.payCur)));//当收、付款账号为信银国际账号时非空(外币账户么)

        nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());

        xmlWriter.writeXElement(tmpXElement);
        xmlWriter.writeEndDocument();//写入报文完成
        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送银行
        if (tmpStrRet[0].length() == 0) {
            StringBuilder tmpSbMsg = new StringBuilder();
            //解析银行返回
            XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
            if (tmpBkReader != null) {
                retDetail.respCode = "0";
                retDetail.respInfo = tmpBkReader.getFirstText("/stream/statusText");
                retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                retDetail.transState = tmpBkReader.getFirstText("/stream/status");
                retDetail.payInfoCode = retDetail.transState;
                retDetail.transAmt = tmpBkReader.getFirstText("/stream/tranAmount");
                deal_ED11308(retDetail);
            } else {
                retDetail.respCode = "-1";
                retDetail.respInfo = tmpSbMsg.toString();
            }
        } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
            retDetail.respCode = "0";
            retDetail.respInfo = tmpStrRet[1];
            retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
            retDetail.transState = PaymentState.FAIL_Payment;
            retDetail.payInfoCode = tmpStrRet[0];
        } else {
            retDetail.respCode = "-1";
            retDetail.respInfo = tmpStrRet[1];
        }
        return retDetail;
    }

    //190801归集下拨
    private RetAtsSglDetail d_190801A(ReqSingle p_req1908) throws Exception {
        RetAtsSglDetail retDetail = new RetAtsSglDetail();
        CITIC01Header bankHeader = new CITIC01Header();
        String payTypeCategory = p_req1908.singleDetail.primaryAct;
        bankHeader.action = "0".equals(payTypeCategory) ? "CMMANSWP" : "CMDWNSWP";
        XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
        xmlWriter.writeStartDocByDeclaration("<?xml version=\"1.0\" encoding=\"GBK\"?>");
        //需要进行对账码拼接以及节点解析，采用XElement进行处理
        //单笔、批量共用节点赋值方法
        XElement tmpXElement = new XElement("stream", "");
        tmpXElement.addChild(new XElement("action", bankHeader.action));
        tmpXElement.addChild(new XElement("userName", bankFront.loginName));
        tmpXElement.addChild(new XElement("clientID", p_req1908.singleDetail.askNumber));
        if ("CMMANSWP".equals(bankHeader.action)) {//上划
            tmpXElement.addChild(new XElement("conAccountNo", p_req1908.singleDetail.recAct));//归集账号
            tmpXElement.addChild(new XElement("accountNo", p_req1908.singleDetail.payAct));
        } else if ("CMDWNSWP".equals(bankHeader.action)) {//下拨
            tmpXElement.addChild(new XElement("coreAccountNo", p_req1908.singleDetail.payAct));//核心账号
            tmpXElement.addChild(new XElement("accountNo", p_req1908.singleDetail.recAct));
        }
        tmpXElement.addChild(new XElement("tranAmount", p_req1908.singleDetail.payAmount));
        tmpXElement.addChild(new XElement("preFlg", "0"));
        tmpXElement.addChild(new XElement("preDate", ""));
        tmpXElement.addChild(new XElement("preTime", ""));
        tmpXElement.addChild(new XElement("abstract", p_req1908.singleDetail.abstractATS));
        nodeAnalysis(p_req1908.singleDetail.srcXElement, tmpXElement, getCharset());
        xmlWriter.writeXElement(tmpXElement);
        xmlWriter.writeEndDocument();//写入报文完成
        String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());//发送银行
        if (tmpStrRet[0].length() == 0) {
            StringBuilder tmpSbMsg = new StringBuilder();
            //解析银行返回
            XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
            if (tmpBkReader != null) {
                retDetail.respCode = "0";
                retDetail.respInfo = tmpBkReader.getFirstText("/stream/statusText");
                retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                retDetail.transState = tmpBkReader.getFirstText("/stream/status");
                retDetail.payInfoCode = retDetail.transState;
                deal_ED11308(retDetail);
            } else {
                retDetail.respCode = "-1";
                retDetail.respInfo = tmpSbMsg.toString();
            }
        } else if (tmpStrRet[0].equals(ConnState.FAIL)) {
            retDetail.respCode = "0";
            retDetail.respInfo = tmpStrRet[1];
            retDetail.reqSeqID = p_req1908.singleDetail.askNumber;
            retDetail.transState = PaymentState.FAIL_Payment;
            retDetail.payInfoCode = tmpStrRet[0];
        } else {
            retDetail.respCode = "-1";
            retDetail.respInfo = tmpStrRet[1];
        }
        return retDetail;
    }

    //1944 状态查询
    public RetAtsSingle d_1944_QrySglPay(ReqQrySingle p_req1944) throws Exception {
        //返回ATS的对象
        RetAtsSingle retAts = new RetAtsSingle(p_req1944.reqHeader);

        RetAtsSglDetail retDetail = new RetAtsSglDetail();
        if ("690803".equals(p_req1944.reqHeader.commandCode)) {
            ReqQryBatPayRec req1998 = new ReqQryBatPayRec(p_req1944);
            req1998.reqHeader.transType = "1998";
            req1998.reqHeader.commandCode = "198808";

            CITIC01BatPayRec tmpBatPay = new CITIC01BatPayRec();
            tmpBatPay.reqHeader = req1998.reqHeader;
            tmpBatPay.setSbLog(this.sbLog);
            tmpBatPay.setLogFlushTime(this.logFlushTime);
            tmpBatPay.bankFront = this.bankFront;
            RetAtsQryBatPayRec ret1998 = tmpBatPay.d_1998_QryBatPay(req1998);
            retDetail = ret1998.convertToSingle();
        } else {


            CITIC01Header bankHeader = new CITIC01Header();
            bankHeader.action = "DLCIDSTT";
            XmlTextWriter xmlWriter = new XmlTextWriter();//发银行报文的XML对象
            writeCommonHeader(xmlWriter, bankHeader);//写入通用的头部节点
            xmlWriter.writeElementString("clientID", p_req1944.askNumber);
            xmlWriter.writeElementClosed("type");
            xmlWriter.writeEndDocument();

            try {
                String[] tmpStrRet = sendToBank(xmlWriter.toXmlString());
                if (tmpStrRet[0].length() == 0) {
                    StringBuilder tmpSbMsg = new StringBuilder();
                    XmlTextReader tmpBkReader = loadBankRespXmlReader(tmpStrRet[1], tmpSbMsg);
                    if (tmpBkReader != null) {
                        String tmpStatus = tmpBkReader.getFirstText("/stream/status");
                        String tmpStatusText = tmpBkReader.getFirstText("/stream/statusText");
                        if (tmpStatus != null && tmpStatus.equals("AAAAAAA")) {
                            if (tmpBkReader.read("/stream/list")) {
                                if (tmpBkReader.readedXElement.getAttrValue("name").equals("userDataList")) {
                                    retDetail.reqSeqID = p_req1944.askNumber;
                                    retDetail.respCode = "0";
                                    retDetail.respInfo = tmpBkReader.readedXElement.getSingleText("row/statusText");
                                    retDetail.payInfoCode = tmpBkReader.readedXElement.getSingleText("row/status");
                                    retDetail.transState = "stt+" + tmpBkReader.readedXElement.getSingleText("row/stt");
                                    if ("AAAAAAB".equals(retDetail.payInfoCode) || "AAAAAAC".equals(retDetail.payInfoCode)) {
                                        retDetail.transState = retDetail.payInfoCode;
                                    }
                                } else {
                                    retDetail.respCode = "-1";
                                    retDetail.respInfo = "未找到userDataList的list";
                                }
                            } else {
                                retDetail.respCode = "-1";
                                retDetail.respInfo = "未找到/stream/list";
                            }
                        } else if (tmpStatus != null && tmpStatus.length() > 0) {
                            if ("ED12001".equals(tmpStatus) || "ED12002".equals(tmpStatus)) {//系统登录中,请稍候再试.
                                retDetail.respCode = "-1";
                            } else {
                                retDetail.respCode = "0";
                            }
                            retDetail.reqSeqID = p_req1944.askNumber;
                            retDetail.payInfoCode = tmpStatus;
                            retDetail.respInfo = tmpStatusText;
                            retDetail.transState = tmpStatus + "+" + tmpStatusText;
                        } else {
                            retDetail.respCode = "-1";
                            retDetail.respInfo = tmpStatusText;
                        }
                    } else {
                        retDetail.respCode = "-1";
                        retDetail.respInfo = tmpSbMsg.toString();
                    }
                } else {
                    retDetail.respCode = "-1";
                    retDetail.respInfo = tmpStrRet[1];
                }
            } catch (Exception e) {
                retDetail.respCode = "-1";
                retDetail.respInfo = e.getMessage();
                e.printStackTrace();
            }
        }
        retAts.writeRetDetail(retDetail);
        return retAts;
    }

    @Override
    public RetAtsSingleBat d_1944BAT_QrySglBatPay(ReqQrySingleBat p_req1944BAT) throws Exception {
        return null;
    }

    private String getPayType() {
        String payType = getBankConfig().getValueAsString("appointPayType", "2B");
        String workTime = getBankConfig().getValueAsString("appointWorkTime");
        if (StringHelper.hasAnyChar(workTime)) {
            String[] workTimes = workTime.split(":");
            if (workTimes.length == 2) {
                if (workTimes[0].startsWith("0")) {
                    workTimes[0] = workTimes[0].substring(1);
                }
                if (workTimes[1].startsWith("0")) {
                    workTimes[1] = workTimes[1].substring(1);
                }
                if (StringHelper.isNumber(workTimes[0]) && StringHelper.isNumber(workTimes[1])) {
                    Date appointDate = new Date();
                    appointDate.setHours(Integer.parseInt(workTimes[0]));
                    appointDate.setMinutes(Integer.parseInt(workTimes[1]));
                    appointDate.setSeconds(0);
                    Date systemDate = new Date();
                    if (appointDate.before(systemDate)) {
                        payType = getBankConfig().getValueAsString("appointPayTypeForNotWork", payType);
                    }
                    System.out.println(payType);
                }
            }

        }
        return payType;
    }
}
